﻿function doEdit() {
    var username = $.trim($("#username").val());
    var password = $.trim($("#password").val());
    if (username && password) {
        $.ajax({
            url: '/admin/user/doedit',
            async: false,
            cache: false,
            type: "post",
            dataType: "json",
            data: "username=" + escape(username) + "&password=" + escape(password),
            success: function (result) {
                if (result.status) {
                    location.href = result.url;
                } else {
                    alert(result.message);
                }
            }
        });
    }
    else {
        alert("用户名和密码不能为空");
    }
}

function doDelete(userId) {
    if(confirm("确定要删除吗？"))
    {
     $.ajax({
            url: '/admin/user/dodelete',
            async: false,
            cache: false,
            type: "post",
            dataType: "json",
            data: "userid=" + escape(userId),
            success: function (result) {
                if (result.status) {
                    location.href = result.url;
                } else {
                    alert(result.message);
                }
            }
        });
    }
}


function doEditPassword() {
    var password = $.trim($("#password").val());
    var comfirmpassword = $.trim($("#confirmpassword").val());
    if (password && comfirmpassword && password == comfirmpassword) {
        $.ajax({
            url: '/admin/user/DoEditPasssword',
            async: false,
            cache: false,
            type: "post",
            dataType: "json",
            data: "password=" + escape(password),
            success: function (result) {
                if (result.status) {
                    alert("修改成功");
                } else {
                    alert(result.message);
                }
            }
        });
    } else {
        alert("请输入正确的密码");
    }
}